package socket;

import io.vertx.core.Context;
import io.vertx.core.Vertx;
import io.vertx.core.net.NetServerOptions;

import java.util.concurrent.atomic.AtomicInteger;

public class Server {
	public static void main(String[] args) {
		Vertx vertx = Vertx.vertx();
		Context context = vertx.getOrCreateContext();
		AtomicInteger index = new AtomicInteger();
		context.put("index", index);

		NetServerOptions NetServerOptions = new NetServerOptions();
		NetServerOptions.setPort(10000);
		vertx.createNetServer(NetServerOptions)
			.connectHandler((netSocket)->{
				netSocket.handler(buffer -> {
					System.out.println(" i am server, receive data:" + buffer.toString());;
				}).write(" data1ToClient")
				;
			}).listen();
		System.out.println("main:"+vertx);

		vertx.deployVerticle(new MyVerticleHttp());
		vertx.deployVerticle(new MyVerticle2());
	}
}
